package com;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.spring.boot.autoconfigure.ShiroAnnotationProcessorAutoConfiguration;
import org.apache.shiro.spring.boot.autoconfigure.ShiroAutoConfiguration;
import org.apache.shiro.spring.boot.autoconfigure.ShiroBeanAutoConfiguration;
import org.apache.shiro.spring.config.web.autoconfigure.ShiroWebAutoConfiguration;
import org.apache.shiro.spring.config.web.autoconfigure.ShiroWebFilterConfiguration;
import org.apache.shiro.spring.config.web.autoconfigure.ShiroWebMvcAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Slf4j
@SpringBootApplication(
        exclude = {
                // 排除shiro自动配置，我们自己实现手动配置
                ShiroWebAutoConfiguration.class,
                ShiroWebFilterConfiguration.class,
                ShiroWebMvcAutoConfiguration.class,
                ShiroBeanAutoConfiguration.class,
                ShiroAutoConfiguration.class,
                ShiroAnnotationProcessorAutoConfiguration.class,
                // 排除数据源自动配置，我们自己实现手动配置
                DataSourceAutoConfiguration.class,
                DataSourceTransactionManagerAutoConfiguration.class
        },
        scanBasePackages = {"com.**"})
@EnableCaching // 开启spring Cache 缓存， 支持注解控制缓存
@EnableScheduling // 开启定时任务
@EnableTransactionManagement // 开启事务
@EnableAspectJAutoProxy(exposeProxy = true) // 开启AOP,暴露代理对象
@EnableAsync // 开启异步任务
public class SpringBootInitProjectApplication {

    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        SpringApplication.run(SpringBootInitProjectApplication.class, args);
        String startBanner =
                "\033[36m"
                        +
                        "==================================================\n"
                        + "╔════════════════════════════════════════════════╗\n"
                        + "                                                \n"
                        + "                  🚀  启动成功!  🚀              \n"
                        + "                                                \n"
                        + "      ╔══════════════════════════════════╗      \n"
                        + "      ║  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  ║      \n"
                        + "      ░  Spring Boot Application Ready   ░      \n"
                        + "       ║  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  ║      \n"
                        + "      ╚══════════════════════════════════╝      \n"
                        + "                                                \n"
                        + "                  ⭐  服务就绪  ⭐               \n"
                        + "                                                \n"
                        + "╚════════════════════════════════════════════════╝\n"
                        + "==================================================\n"
                        + "\033[0m";

        log.info("\n" + startBanner); // 打印图标（加换行符让格式更清晰）
        log.info("启动成功，耗时：{} ms", System.currentTimeMillis() - startTime);
    }
}
